package question4;

public class OrderDetail {
    private int quantity;
    private Product product;
    private Order order;

    // 构造方法
    public OrderDetail(int quantity, Product product, Order order) {
        this.quantity = quantity;
        this.product = product;
        this.order = order;
    }

    public int getQuantity() {
        return quantity;
    }

    public Product getProduct() {
        return product;
    }

    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    // 计算该订单详情的小计（商品单价×数量）
    public double calculateSubTotal() {
        return product.getPriceForQuantity(quantity);
    }

    // 计算该订单详情的总重量（商品单重×数量）
    public double calculateWeight() {
        return product.getWeight() * quantity;
    }
}
